function [fitting,xData,yData] = fineFitXe131FID(~, signal, varargin)
    p=inputParser; p.KeepUnmatched = true;
    p.addParameter('rate', 2e3, @(x) x>0);
    p.addParameter('targetResolution', 1e-3, @(x) x>0.0)
    p.addParameter('guessFrequency', 75.0, @(x) x>0.0);
    p.addParameter('isPlot',false,@islogical);
    p.parse(varargin{:});
    
    fidSignal = signal.getNodeData(1);
    fidEnvelope = signal.getNodeData(2);
    
    [xData, yData] = prepareCurveData( fidEnvelope.x, fidEnvelope.y );
    ft = fittype( 'exp1' );
    opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
    opts.Display = 'Off';
    opts.StartPoint = [max(fidEnvelope.y) -mean(fidEnvelope.x)];

    [fitting.result, fitting.gof] = fit( xData, yData, ft, opts );
    fitting.amplitude = fitting.result.a;
    fitting.tau = abs(1.0/fitting.result.b);

    %%
    L = 2^nextpow2(p.Results.rate/p.Results.targetResolution);
    fList= (0:L/2)*p.Results.rate/L; Y = fft(fidSignal.y, L);
    P2 = abs(Y/L); P1 = P2(1:L/2+1); P1(2:end-1) = 2*P1(2:end-1);
    
    fitting.fft.value = P1;
    fitting.fft.fList = fList;
    idx = (fList > p.Results.guessFrequency-2.0 & fList < p.Results.guessFrequency+2.0);
%     [fitting.fft.peak, fitting.fft.center, fitting.fft.width] = findpeaks(fitting.fft.value(idx), fitting.fft.fList(idx), 'NPeaks', 1, 'SortStr', 'descend');
    [fpeak, fcenter, fwidth] = findpeaks(fitting.fft.value(idx), fitting.fft.fList(idx), 'NPeaks', 1, 'SortStr', 'descend');    
    [xData, yData] = prepareCurveData( fList(and(fList<(fcenter+5*fwidth) , fList>(fcenter-5*fwidth))) , ...
                sqrt(P1(and(fList<(fcenter+5*fwidth) , fList>(fcenter-5*fwidth))) ));
            
    ft = fittype( 'A/sqrt((x-cf)^2+w^2)+bg', 'independent', 'x', 'dependent', 'y' );
    opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
    opts.Display = 'Off';
    opts.StartPoint = [sqrt(fpeak)*fwidth 0 fcenter fwidth];
    opts.Lower = [-Inf 0 fcenter-1 0];
    opts.Upper = [Inf Inf fcenter+1 Inf];
    opts.TolFun = 1e-16;
    opts.TolX = 1e-16;
    
    [fitting.resultF131, fitting.gofF131] = fit( xData, yData, ft, opts );
    fitting.f131 = fitting.resultF131.cf;
    if p.Results.isPlot
        figure( 'Name', 'untitled fit 1' );
        h = plot( fitting.resultF131, xData, yData );grid on;
    end
end

